<?php
session_start();
include_once("model/user.model.php");
include_once("controller/main.control.php");

function simple_header() {
    echo "<img style='padding:0 0 0 204px' src='image/banners/title.png'>";
}

function page_header() //website header
{
	$username = $_SESSION['username'];
	$usertype = $_SESSION['member_type'];
	$type_id = $_SESSION['type_id'];

	if ($username && $usertype==1) //admin -> add VIEW TRANSACTION & VIEW MEMBER pages
	{
		echo "<img style='padding:0 0 0 204px' src='image/banners/title.png'>
		<div id='tabs'><ul><li><a href='index.php'><span>HOME</span></a></li>
		<li><a href='admin_view_vacancy.php'><span>VIEW VACANCY</span></a></li>
		<li><a href='view_transaction.php?admin_id=".$type_id."'><span>VIEW TRANSACTION</span></a></li>
                <li><a href='search.php'><span>SEARCH</span></a></li>
                <li><a href='view_member.php'><span>VIEW MEMBER</span></a></li>
		<li><a href='logout.php'><span>LOGOUT</span></a></li>
		</ul></div>";
	}

	else if ($username && $usertype==2) //landlord
	{
		echo "<img style='padding:0 0 0 204px' src='image/banners/title.png'>
		<div id='tabs'><ul>
            <li><a href='index.php'><span>HOME</span></a></li>
            <li><a href='view_vacancy.php'><span>VIEW VACANCY</span></a></li>
			<li><a href='view_transaction.php?landlord_id=".$type_id."'><span>VIEW TRANSACTION</span></a></li>
            <li><a href='search.php'><span>SEARCH</span></a></li>
		<li><a href='logout.php'><span>LOGOUT</span></a></li>
  		</ul></div>";
	}

	else if ($username && $usertype==3) //tenant
	{
		echo "<img style='padding:0 0 0 204px' src='image/banners/title.png'>
		<div id='tabs'><ul>
    	<li><a href='index.php'><span>HOME</span></a></li>
    	<li><a href='view_vacancy.php'><span>VIEW VACANCY</span></a></li>
		<li><a href='view_transaction.php?tenant_id=".$type_id."'><span>VIEW TRANSACTION</span></a></li>
    	<li><a href='search.php'><span>SEARCH</span></a></li>
		<li><a href='logout.php'><span>LOGOUT</span></a></li>
  		</ul></div>";
	}

	else if ($usertype != 1 && $usertype != 2 && $usertype != 3) //guest (not-login)
	{
		echo "<img style='padding:0 0 0 204px' src='image/banners/title.png'>
		<div id='tabs'><ul>
    	<li><a href='index.php'><span>HOME</span></a></li>
    	<li><a href='view_vacancy.php'><span>VIEW VACANCY</span></a></li>
        <li><a href='search.php'><span>SEARCH</span></a></li>
	<li><a href='login.php'><span>LOGIN</span></a></li>
    	<li><a href='register.php'><span>REGISTER</span></a></li>
  		</ul></div>";
	}
}

function navibar() //left navibar
{
	$username = $_SESSION['username'];
	$usertype = $_SESSION['member_type'];
	$userid = $_SESSION['member_id'];
        $user = new User();
	  
	if($usertype==2)
	{
            $member_id = $user->get_landlord_id($userid);
	}
	else if($usertype==3)
	{
            $member_id = $user->get_tenant_id($userid);
	}
        else if ($usertype==1)
        {
            $member_id = $user->get_admin_id($userid);
        }
	
	if ($username && $usertype==1) //admin
	{
		echo "<img src='image/banners/profile.png'><br>";
		echo "<p>Hello, <b><font color=#fee900>".$username."</font></b><br>
		<i><b>Admin</b></i><br><br>
		<a href='view_profile.php?admin_id=" .$member_id. "'>View Profile</a><br>
		<a href='edit_profile.php'>Edit Profile</a></p>";
	}	
	
	else if ($username && $usertype==2) //landlord
	{
		echo "<img src='image/banners/profile.png'><br>";
		echo "<p>Hello, <b><font color=#000940>".$username."</font></b><br>
		<i><b>Landlord</b></i><br><br>
		<a href='view_profile.php?landlord_id=" .$member_id. "'>View Profile</a><br>
		<a href='edit_profile.php'>Edit Profile</a></p><br>";
		check_empty_rating();
	}	

	else if ($username && $usertype==3) //tenant
	{
		echo "<img src='image/banners/profile.png'><br>";
		echo "<p>Hello, <b><font color=#8a0000>".$username."</font></b><br>
		<i><b>Tenant</b></i><br><br>
		<a href='view_profile.php?landlord_id=" .$member_id. "'>View Profile</a><br>
		<a href='edit_profile.php'>Edit Profile</a></p><br>";
                check_empty_rating();
		
	}	

	else if ($usertype != 1 && $usertype != 2 && $usertype != 3) //guest (not-login)
	{
		echo "<img src='image/banners/login.png'><br>";
		echo login_form();
	}
}

function title() //content on homepage
{
	echo "<img src='image/banners/welcome.png'>
	<br><br><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 
	incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud 
	exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><br>";
}

function vacancy_options() //on vacancy pages
{
	$username = $_SESSION['username'];
	$usertype = $_SESSION['member_type'];
	echo "<img src='image/banners/options.png'><br>";
	
	if ($usertype==1) //admin
	{
		echo "<p><a href='view_editable_vacancy.php'>Edit Vacancy</a><br>
		<a href='delete_vacancy.php'>Delete Vacancy</a></p><br>";
	}
	
	else if ($usertype==2) //landlord
	{
		echo "<p><a href='add_vacancy.php'>Add Vacancy</a><br>
    	<a href='view_editable_vacancy.php'>Edit Vacancy</a><br>
		<a href='delete_vacancy.php'>Delete Vacancy</a></p><br>";
	}
	else //tenant & guest
	{
		echo "<p><a href='view_vacancy.php'>View Vacancy</a><br>";
	}
}

function transaction_option()
{
    $username = $_SESSION['username'];
    $usertype = $_SESSION['member_type'];
    echo "<img src='image/banners/options.png'	><br>";

    if ($usertype==1) //admin
    {
	echo "<p><a href='add_vacancy.php'>Add Vacancy</a><br>
   	<a href='view_editable_vacancy.php'>Edit Vacancy</a><br>
	<a href='delete_vacancy.php'>Delete Vacancy</a></p><br>";
    }

    else if ($usertype==2) //landlord
    {
	echo "<p><a href='add_vacancy.php'>Add Vacancy</a><br>
    	<a href='view_editable_vacancy.php'>Edit Vacancy</a><br>
	<a href='delete_vacancy.php'>Delete Vacancy</a></p><br>";
    }
    else //tenant & guest
    {
	echo "<p><a href='view_vacancy.php'>Neighbourhood</a><br>
    	<a href='view_vacancy.php'><span>Nearest MRT</span></a></p><br>";
    }
}

function admin_view_member()
{
    $username = $_SESSION['username'];
    $usertype = $_SESSION['member_type'];
    echo "<img src='image/banners/options.png'	><br>";
    if($usertype==1) {
        echo "<p><a href='view_member.php?type=landlord'>Landlord</a><br>
    	<a href='view_member.php?type=tenant'>Tenant</a><br>
        <a href='view_member.php>All Members</a>";
    } else {
        echo "Please Log in as Admin first! <br><br>
             <a href='login.php>Log in here<a><br>
             <a href='index.php'>Back</a>";
    }
}

function footer() 
{
	echo "<p>FYP Team C2009119 ?2009<br>
    School of Information & Communications Technology, Republic Polytechnic, Singapore<br>
	<a href='aboutus.php'>About Us</a><br> <a href='sitemap.php'>Site Map</a></p>";
}

?>